package hlhj.com.carviewpad.adapter

import android.content.Context
import android.os.Environment
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.mymvp.log
import com.makeramen.roundedimageview.RoundedImageView
import hlhj.com.carviewpad.Constant
import hlhj.com.carviewpad.R
import hlhj.com.carviewpad.atys.MainActivity
import hlhj.com.carviewpad.javabean.AdvBean

/**
 * Created by Never Fear   on 2018\12\28 0028.
Never More....
 */
class PreviewListAdp(private val datas:ArrayList<AdvBean>) :BaseQuickAdapter<AdvBean,BaseViewHolder>(R.layout.preview_item,datas) {
    override fun convert(helper: BaseViewHolder?, item: AdvBean?) {
        val imageView = helper?.getView<RoundedImageView>(R.id.itemImg)
        if (helper?.adapterPosition==MainActivity.cP){
            imageView?.borderWidth=4f
        }else{
            imageView?.borderWidth=0f
        }
        if (item?.type.equals("1")){
            Constant.coverList.forEachIndexed { index, s ->
                if (s.split("_").size>1){
                    if (s.split("_")[1].split(".")[0].equals(item?.id)){
                        Glide.with(mContext).load(s)
                                .into(helper?.getView(R.id.itemImg))
                    }
                }
            }
        }else{
            Glide.with(mContext).load(item?.filePath)
                    .into(helper?.getView(R.id.itemImg))
        }


    }
}